<?php
/**
 *  💡 免责声明：本软件不得用于商业用途，仅做学习交流
 *  ⚠️ 权利声明：本软件由版权人提供产品技术支持
 *  📅 项目编号：NX2025-0135
 */
namespace App\Api\Controllers\Auths;

use App\Api\BaseApi;
use App\Models\MemberTopupOrder;

class PaymentApi extends BaseApi
{
    public function rechargeApplication()
    {
        $request = self::validate([
            'amount' => 'required',
            'payment_gateway' => 'required|in:1,2,3',
            'certificate' => 'required',
        ]);
        MemberTopupOrder::query()->create([
            'user_id' => self::UserId(),
            'order_no' => genOrderNumber('C'),
            'amount' => $request['amount'],
            'payment_gateway' => $request['payment_gateway'],
            'certificate' => $request['certificate'],
            'status' => 1,
        ]);
        return responses('已提交审核！待工作人员审核通过,即将到账');
    } //充值申请

    public function rechargeList()
    {
        $res = MemberTopupOrder::query()->where('user_id', self::UserId())->latest()->simplePaginate(request('perPage', 10));
        return responses($res);
    }
}
